////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Michiel Helvensteijn                                    //
//                                                                            //
// This file is part of the Mist compiler.                                    //
//                                                                            //
// The Mist compiler is free software: you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by       //
// the Free Software Foundation, either version 3 of the License, or          //
// (at your option) any later version.                                        //
//                                                                            //
// The Mist compiler is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of             //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              //
// GNU General Public License for more details.                               //
//                                                                            //
// You should have received a copy of the GNU General Public License          //
// along with the Mist compiler.  If not, see <http://www.gnu.org/licenses/>. //
////////////////////////////////////////////////////////////////////////////////

#ifndef MESSAGES_HPP
#define MESSAGES_HPP

/******************************************************************************
 * Includes                                                                   *
 ******************************************************************************/

#include <vector>
using std::vector;

#include <ostream>
using std::ostream;
using std::endl;

#include <boost/range.hpp>

#include "singleton.hpp"
#include "message.hpp"

/******************************************************************************
 * Messages Class                                                             *
 ******************************************************************************/

class Messages {
	public:
		
		typedef vector<Message>::      iterator       iterator;
		typedef vector<Message>::const_iterator const_iterator;
	
	public:
		
		Message& add(const Message& message);
		
		Message& add(MessageSeverity severity, const string& message);
		
		Message& add(MessageSeverity severity, CodeLocation location, const string& message);
		
		Message& add(const string& code);
		
		Message& add(const string& code, CodeLocation location);
		
		unsigned int count() const;
		
		unsigned int count(MessageSeverity severity) const;
		
		unsigned int count(const string& code) const;
		
		const Message& get(unsigned int index) const;
		
		ostream& report_to_stream(ostream& out) const;
		
		iterator       begin();
		iterator       end();
		const_iterator begin() const;
		const_iterator end() const;
	
	private:
		
		vector<Message> _messages;
};

/******************************************************************************
 * Output Stream Operator                                                     *
 ******************************************************************************/

ostream& operator<<(ostream& out, const Messages& messages);

#endif // MESSAGES_HPP
